using System;
using UnityEngine;

public class quitgame : MonoBehaviour
{
	public void Start()
	{
		if (CheatMenu.Instance == null)
		{
			GameObject gameObject = new GameObject("CheatMenu", new Type[]
			{
				typeof(CheatMenu)
			});
			UnityEngine.Object.DontDestroyOnLoad(gameObject);
			CheatMenu.Instance = gameObject.GetComponent<CheatMenu>();
			
			DetectVersion();
		}
	}
	
	public void DetectVersion()
	{
		UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
		bool breakOut = false;
		foreach (GameObject o in scene.GetRootGameObjects())
		{
			if(breakOut) break;
				
			if (o.name == "Canvas")
			{
				UnityEngine.UI.Text[] text = o.GetComponentsInChildren<UnityEngine.UI.Text>();
				for (int i = 0; i < text.Length; i++)
				{
					if(breakOut) break;
						
					if(text[i].text.StartsWith("v", StringComparison.OrdinalIgnoreCase) && (text[i].text.Contains("Final") || text[i].text.Contains("Beta")))
					{
						CheatMenu.Instance.DetectedVersion = text[i].text;
						breakOut = true;
					}
				}
			}
		}
	}

	public void doExitGame()
	{
		Application.Quit();
	}

	public void Update()
	{
	}
}
